home *** CD-ROM | disk | FTP | other *** search
- property myDelay, mySprite, myMemberList, myMemberListPointer, myPausedState, myCastLib, myTimerFlag, myCycles, CycleCounter
-
- on new me, theSprite, theTicks, cycles
- myCastLib = castLib("Characters").number
- mySprite = theSprite
- myDelay = theTicks
- myPausedState = 1
- myMemberList = []
- myCycles = cycles
- CycleCounter = 1
- puppetSprite(mySprite, 1)
- getMyMemberList(me)
- preloadMyMembers(me)
- myTimerFlag = the timer
- return me
- end
-
- on destruct me
- puppetSprite(mySprite, 0)
- end
-
- on getMyMemberList me
- firstMember = the member of sprite mySprite
- myMemberListPointer = 1
- memberName = member(firstMember).name
- startNum = the number of member firstMember
- endNum = startNum + the number of castMembers of castLib myCastLib
- repeat with mNum = startNum to endNum
- if member(mNum).type <> #empty then
- if member(mNum).name = memberName then
- add(myMemberList, mNum)
- else
- exit repeat
- end if
- next repeat
- end if
- exit repeat
- end repeat
- end
-
- on preloadMyMembers me
- repeat with x = 1 to count(myMemberList)
- preloadMember(member(getAt(myMemberList, x), myCastLib))
- end repeat
- end
-
- on stepFrame me
- Animate(me)
- end
-
- on Animate me
- if timeToAnimate(me) then
- myMemberListPointer = myMemberListPointer + 1
- if myMemberListPointer > count(myMemberList) then
- myMemberListPointer = 1
- CycleCounter = CycleCounter + 1
- if CycleCounter > myCycles then
- CycleCounter = 0
- myPausedState = 1
- end if
- end if
- set the member of sprite mySprite to getAt(myMemberList, myMemberListPointer)
- end if
- end
-
- on timeToAnimate me
- if myPausedState = 0 then
- if the timer >= (myTimerFlag + myDelay) then
- myTimerFlag = the timer
- return 1
- end if
- else
- if the timer >= (myTimerFlag + (myDelay * 2)) then
- myTimerFlag = the timer
- if CycleCounter = 0 then
- CycleCounter = 1
- return 0
- end if
- x = random(10)
- if x > 8 then
- myPausedState = 0
- myTimerFlag = the timer
- return 1
- end if
- myTimerFlag = the timer
- end if
- end if
- return 0
- end
-
- on actorType me
- return #animator
- end
-